<extend name="Layout:layout_content" />
<block name="body_main">
    <div class="grid-parent xsui-page-header">
        <div class="grid-60 mobile-grid-100 grid-parent">
            <a href="{:U('department_edit')}" class="xsui-btn ui-state-default xsui-lnk-add-dialog"><i class="fa fa-plus"></i>新增</a>
            <a href="{:U('department_export')}" class="xsui-btn ui-state-default"><i class="fa fa-save"></i>导出</a>
            <a href="#" class="xsui-btn ui-state-default xsui-lnk-expand">
                <if condition="$conf_tree_state_expand">
                <i class="fa fa-plus-square-o"></i><span>全部展开</span>
                <else/>
                <i class="fa fa-minus-square-o"></i><span>全部收起</span>
                </if>
            </a>
        </div>
        <div class="grid-40 mobile-grid-100 grid-parent xsui-text-right">
            <a href="#" class="xsui-btn ui-state-default xsui-lnk-refresh"><i class="fa fa-refresh"></i>刷新</a>
            <span class="xsui-input-group">
                <form method="get">
                    <input type="text" name="search_key" value="{$search.search_key}" placeholder="标题" />
                    <button type="submit" class="ui-state-default"><i class="fa fa-search"></i>搜索</button>
                </form>
            </span>
        </div>
    </div>
    <div id="grid-container">
        {$content}
    </div>
</block>
<block name="body_after">    
    <script type="text/javascript">
        $(function () {
            // 状态显示处理 2016-1-18 SoChishun Added.
            // 如：<td class="status"><a href="AddonU('change_status','id='.$vo['id'].'&status=varstatus')" data-value="$vo.status" title="点击隐藏" class="xsui-success"><i class="fa fa-check fa-fw"></i></a></td>
            $('td.status a').togglelink();
            // 动态更改排序 2015-10-24 SoChishun Added.
            $('td.sort input').blur(function () {
                var $input = $(this);
                change_sort($input);
            })
            // 自动添加展开收缩图标 2015-10-29 SoChishun Added.
            $('tr.xsui-table-tree-l1').each(function () {
                if ($(this).next().is('.xsui-table-tree-l2')) {
                    $(this).find('.prefix').after('<a href="#" class="xsui-icon-only xsui-lnk-expend"><i class="fa fa-minus-square-o fa-fw"></i></a>');
                }
            });
            // 动态展开收缩 2015-10-29 SoChishun Added.
            $('td .lnk-expend').click(function () {
                var $a = $(this);
                var $i = $a.find('i');
                if ($i.hasClass('fa-plus-square-o')) {
                    $i.toggleClass('fa-plus-square-o').toggleClass('fa-minus-square-o');
                    $a.parent().parent().nextUntil('.xsui-table-tree-l1').show();
                } else {
                    $i.toggleClass('fa-plus-square-o').toggleClass('fa-minus-square-o');
                    $a.parent().parent().nextUntil('.xsui-table-tree-l1').hide();

                }
                return false;
            })
            // 展开全部 2015-10-29 SoChishun Added.
            $('.xsui-page-header .lnk-expand').click(function(){
                var $i=$(this).find('i');
                if ($i.hasClass('fa-plus-square-o')) {
                    $i.toggleClass('fa-plus-square-o').toggleClass('fa-minus-square-o').next().text('全部收起');
                    $('.xsui-table-tree-l1 .lnk-expend i').removeClass('fa-plus-square-o').removeClass('fa-minus-square-o').addClass('fa-minus-square-o');
                    $('.xsui-table-tree-l2,.xsui-table-tree-l3').show();
                } else {
                    $i.toggleClass('fa-plus-square-o').toggleClass('fa-minus-square-o').next().text('全部展开');
                    $('.xsui-table-tree-l1 .lnk-expend i').removeClass('fa-plus-square-o').removeClass('fa-minus-square-o').addClass('fa-plus-square-o');
                    $('.xsui-table-tree-l2,.xsui-table-tree-l3').hide();

                }
                return false;
            })
        })
    </script>
</block>